const directiveObj = {
    install(Vue) {
      //全局自定义指令
      Vue.directive("fofo", {
        inserted(el) {
          if (el.nodeName === "TEXTAREA" || el.nodeName === "INPUT") {
            el.focus();
          } else {
            const theInput = el.querySelector("input");
            const thetextarea = el.querySelector("textarea");
            if (theInput) theInput.focus();
            if (thetextarea) thetextarea.focus();
          }
          //通过 query 找到里面的input对象，然后对该对象使用 focus 方法，使其获得焦点
          // const theInput = el.querySelector("input");
          // theInput.focus();
          // console.log(el);
        },
        update (el) {
          if (el.nodeName === "TEXTAREA" || el.nodeName === "INPUT") {
            el.focus();
          } else {
            const theInput = el.querySelector("input");
            const thetextarea = el.querySelector("textarea");
            if (theInput) theInput.focus();
            if (thetextarea) thetextarea.focus();
          }
        },
      });
    },
  };

  export default directiveObj